It’s finally summertime here in New York, which means bike season is upon us. Since the turn of the millennium, cycling as a mode of transportation has exploded in the US; the Census Bureau recorded a 60 percent increase in bike commuting between 2000 and 2012. This increase in participation has gone hand in hand with the expansion of biking facilities and infrastructure. According to the ever reliable Thrillist, here are “The Best Cities in America for Cyclists”, in no particular order:
- Chicago, IL
- Boulder, CO
- Minneapolis-Saint Paul, MN
- Washington, DC
- Seattle, WA
- New York City, NY
- Madison, WI
- Boise, ID
- San Francisco, CA
- Portland, OR
I want to visualize the existing bike network for each city and chart its growth over time. By “bike network”, I mean Class I and Class II infrastructure, which refer to fully separated cycle tracks (e.g. Hudson Greenway) and striped bike lanes (protected or not). Bike-friendly municipalities should have a “low-stress” web of streets that cyclists feel comfortable traveling on, and Class III facilities like sharrows (e.g. painted chevron, stick figure on a bike) shouldn’t count - they strike me as totally ineffective.
To accomplish the above, we need data on the facility type, length, installation year, and spatial geometry of each lane. After perusing the open data portals for each municipality, only Washington DC, Seattle, New York City, Madison, San Francisco, and Portland fit the bill. The GitHub repo has a script with the dirty work of making sure fields and projection systems play nicely with one another, but for now let’s load the clean data like so:
#=============
#Import bike data
#=============
#Bike networks
dc <- st_read("E:/Data/PBL-Networks/Shapefiles/Washington.shp",quiet = T)
seattle <- st_read("E:/Data/PBL-Networks/Shapefiles/Seattle.shp",quiet = T)
nyc <- st_read("E:/Data/PBL-Networks/Shapefiles/New_York_City.shp",quiet = T)
madison <- st_read("E:/Data/PBL-Networks/Shapefiles/Madison.shp",quiet = T)
sfca <- st_read("E:/Data/PBL-Networks/Shapefiles/San_Francisco.shp",quiet = T)
pdx <- st_read("E:/Data/PBL-Networks/Shapefiles/Portland.shp",quiet = T)
#Combine into one frame
bike_net <- rbind(dc,seattle,nyc,madison,sfca,pdx) %>%
rename("Facility_Type" = Fclty_T,
"Facility_Class" = Fclty_C,
"Install_Year" = Instl_Y)
Now that we’ve got everything in a Simple Features-friendly data frame - where geographic data is stored in a list-column - it is incredibly easy to make an interactive plot for each city with a few lines of code using the tmap package.
#=============
#Interactive map
#=============
#Basemap
basemap = leaflet::providers$CartoDB.Positron
#Facet for each city
plot_facet <- tm_shape(bike_net) +
tm_lines(id = "pbl",col = "green",lwd = 2,legend.lwd.show = F,
popup.vars = c("Facility" = "Facility_Type",
"Miles" = "Miles",
"Install Year" = "Install_Year"),
popup.format = list(Miles = list(digits = 4),
Install_Year = list(big.mark = ""))) +
tm_facets(by = "City",nrow = 3,free.coords = T) +
tmap_mode("view") +
tm_view(basemaps = basemap) +
tm_layout(main.title = "Bike Lane Networks in Select US Cities",
between.margin = 1)
#Plot
plot_facet